<!--
描述：招生管理-成绩设置-编辑组件
开发人：hqj
开发日期：2019年02月26日
-->
<template lang="pug">
    kalix-dialog.user-add(bizKey="examScoreSetting" ref="kalixBizDialog"
    v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
        div.el-form(slot="dialogFormSlot")
            el-form-item.s-flex_item(label="考生专业" prop="major" v-bind:rules="rules.major" v-bind:label-width="labelWidth")
                kalix-dict-select(v-model="formModel.major" appName="enrolment" dictType="考生专业")
            el-form-item.s-flex_item(label="省份" prop="province" v-bind:rules="rules.province" v-bind:label-width="labelWidth")
                el-input(v-model="formModel.province")
            el-form-item.s-flex_item(label="分数转换系数" prop="coefficient" v-bind:rules="rules.coefficient" v-bind:label-width="labelWidth")
                el-input(v-model="formModel.coefficient")
</template>

<script type="text/ecmascript-6">
    import FormModel from './model'
    import {ExamScoreSettingURL} from '../../config.toml'

    export default {
        name: 'ExamScoreSettingAdd',
        data() {
            var checkCoefficient = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('请输入分数转换系数'));
                }
                if (/^((\d|[123456789]\d)(\.\d+)?|100)$/.test(value)) {
                    callback();
                } else {
                    callback(new Error('请输入0～100之间的数字值'));
                }
            };
            return {
                formModel: Object.assign({}, FormModel),
                rules: {
                    major: [{required: true, message: '请选择考生专业', trigger: 'change'}],
                    province: [{required: true, message: '请输入省份', trigger: 'blur'}],
                    coefficient: [{required: true, validator: checkCoefficient, trigger: 'blur'}]
                },
                targetURL: ExamScoreSettingURL,
                labelWidth: '180px',
            }
        },
        created() {
        },
        mounted() {
        },
        methods: {
        }
    }
</script>

<style scoped lang="stylus">
    .el-form
        padding 30px 70px 30px 20px

    .popover
        height 40px
        display flex
        align-items center
        padding-left 16px
        font-size 20px
</style>
